<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/29 0029
 * Time: 14:24
 */

namespace Cuke\Models;


use Phalcon\Mvc\Model;

/**
 * 模型基类
 * @package Cuke\Models
 */
class ModelBase extends Model
{

    public function initialize()
    {
        $this->setup([
            'notNullValidations'=>false
        ]);
    }


    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return static
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return static
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * 获取第一条错误信息
     * @return null|Model\MessageInterface
     */
    public function getMessage()
    {
        $messages = $this->getMessages();
        foreach ($messages as $message){
            return $message;
        }
        return null;
    }
}